package cn.kuick.match8.test1;

import java.util.*;

import cn.kuick.utils.StringUtils;

public class CornerValleyConjecture {

	public static void check(List<String> result, int m) {
		if (m > 1) {
			if (m % 2 == 1) {
				result.add(String.valueOf(m));
				
				check(result, m * 3 + 1);
			} else {
				check(result, m / 2);
			}
		}
	}
	
	public static String checkAll(int m) {
		List<String> result = new ArrayList<>();
		check(result, m);
		
		if (result.size() > 0) {
			return StringUtils.join(" ", result);
		} else {
			return "No number can be output !";
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		try {
			int n = scan.nextInt();
			
			for (int i=0; i<n; i++) {
				int m = scan.nextInt();
				String result = checkAll(m);
				System.out.println(result);
			}
		} finally {
			scan.close();
		}
	}
}